#ifndef _BOOT_SYS_CONFIG_H_
#define _BOOT_SYS_CONFIG_H_

#include <sys_define.h>

#define SYS_CHIP_MODULE			ALI_S3602		/* Chip configuration */

//#define SYS_CHIP_CLOCK			27000000		/* Extarnal clock */
//#define SYS_CPU_CLOCK			216000000		/* CPU clock */

#define SYS_FLASH_BASE_ADDR		0xafc00000		/* Flash base address */

#define SYS_SDRAM_SIZE			8				/*  4 ==  4M,  8 ==  8M,
												   16 == 16M, 32 == 32M,
												   64 == 64M, etc. */
#define SYS_GPIO_MODULE			M6303GPIO		/* GPIO configuration */

/*******Memory Mapping*******/
#if ( SYS_SDRAM_SIZE == 2 )
#define __MM_BUF_TOP_ADDR		0XA0200000
#define __MM_FB0_Y_LEN			0X65400
#define __MM_FB0_C_LEN			0X32C00
#define __MM_FB1_Y_LEN			0
#define __MM_FB1_C_LEN			0
#define __MM_FB2_Y_LEN			0
#define __MM_FB2_C_LEN			0
#define __MM_OSD_LEN			0
#define __MM_VBV_LEN			0X10000
#define __MM_DMX_SI_LEN			0
#define __MM_DMX_SI_TOTAL_LEN	(__MM_DMX_SI_LEN*12)
#define __MM_SI_VBV_OFFSET		0
#define __MM_DMX_DATA_LEN		0
#define __MM_DMX_PCR_LEN		0
#define __MM_DMX_AUDIO_LEN		0
#define __MM_DMX_VIDEO_LEN		0
#define __MM_DMX_AVP_LEN		(__MM_DMX_VIDEO_LEN+__MM_DMX_AUDIO_LEN+__MM_DMX_PCR_LEN)

#define __MM_FB0_Y_START_ADDR	((__MM_BUF_TOP_ADDR - __MM_FB0_Y_LEN)&0XFFFFFF00)
#define __MM_FB0_C_START_ADDR	((__MM_FB0_Y_START_ADDR - __MM_FB0_C_LEN)&0XFFFFFF00)
#define __MM_FB1_Y_START_ADDR	((__MM_FB0_C_START_ADDR - __MM_FB1_Y_LEN)&0XFFFFFF00)
#define __MM_FB1_C_START_ADDR	((__MM_FB1_Y_START_ADDR - __MM_FB1_C_LEN)&0XFFFFFF00)
#define __MM_FB2_Y_START_ADDR	((__MM_FB1_C_START_ADDR - __MM_FB2_Y_LEN)&0XFFFFFF00)
#define __MM_FB2_C_START_ADDR	((__MM_FB2_Y_START_ADDR - __MM_FB2_C_LEN)&0XFFFFFF00)
#define __MM_OSD_START_ADDR		((__MM_FB2_C_START_ADDR - __MM_OSD_LEN)&0XFFFFFFF0)
#define __MM_VBV_START_ADDR		((__MM_OSD_START_ADDR - __MM_VBV_LEN)&0XFFFFFF00)
#define __MM_DMX_AVP_START_ADDR	((__MM_VBV_START_ADDR - __MM_SI_VBV_OFFSET - __MM_DMX_DATA_LEN - __MM_DMX_AVP_LEN)&0XFFFFFFFC)
#define __MM_HEAP_TOP_ADDR		__MM_DMX_AVP_START_ADDR
#define __MM_MAF_START_ADDR		0XFFFFFFFF
#define __MM_DVW_START_ADDR		0XFFFFFFFF
#elif ( SYS_SDRAM_SIZE == 4 )
#define __MM_BUF_TOP_ADDR		0XA0400000
#define __MM_FB0_Y_LEN			0X65400
#define __MM_FB0_C_LEN			0X32C00
#define __MM_FB1_Y_LEN			0
#define __MM_FB1_C_LEN			0
#define __MM_FB2_Y_LEN			0
#define __MM_FB2_C_LEN			0
#define __MM_MAF_LEN			0
#define __MM_DVW_LEN			0
#define __MM_OSD_LEN			0
#define __MM_VBV_LEN			0X10000
#define __MM_DMX_SI_LEN			0
#define __MM_DMX_SI_TOTAL_LEN	(__MM_DMX_SI_LEN*28)
#define __MM_SI_VBV_OFFSET		0
#define __MM_DMX_DATA_LEN		0
#define __MM_DMX_PCR_LEN		0
#define __MM_DMX_AUDIO_LEN		0
#define __MM_DMX_VIDEO_LEN		0
#define __MM_DMX_AVP_LEN		(__MM_DMX_VIDEO_LEN+__MM_DMX_AUDIO_LEN+__MM_DMX_PCR_LEN)
#define __MM_TTX_BS_LEN			0
#define __MM_TTX_PB_LEN			0
#define __MM_SUB_BS_LEN			0
#define __MM_SUB_PB_LEN			0

#define __MM_FB0_Y_START_ADDR	((__MM_BUF_TOP_ADDR - __MM_FB0_Y_LEN)&0XFFFFFF00)
#define __MM_FB0_C_START_ADDR	((__MM_FB0_Y_START_ADDR - __MM_FB0_C_LEN)&0XFFFFFF00)
#define __MM_FB1_Y_START_ADDR	((__MM_FB0_C_START_ADDR - __MM_FB1_Y_LEN)&0XFFFFFF00)
#define __MM_FB1_C_START_ADDR	((__MM_FB1_Y_START_ADDR - __MM_FB1_C_LEN)&0XFFFFFF00)
#define __MM_FB2_Y_START_ADDR	((__MM_FB1_C_START_ADDR - __MM_FB2_Y_LEN)&0XFFFFFF00)
#define __MM_FB2_C_START_ADDR	((__MM_FB2_Y_START_ADDR - __MM_FB2_C_LEN)&0XFFFFFF00)
#define __MM_MAF_START_ADDR		((__MM_FB2_C_START_ADDR - __MM_MAF_LEN)&0XFFFFFC00)
#define __MM_DVW_START_ADDR		((__MM_MAF_START_ADDR - __MM_DVW_LEN)&0XFFFFFFF0)
#define __MM_OSD_START_ADDR		((__MM_DVW_START_ADDR - __MM_OSD_LEN)&0XFFFFFFF0)
#define __MM_VBV_START_ADDR		((__MM_OSD_START_ADDR - __MM_VBV_LEN)&0XFFFFFF00)
#define __MM_DMX_AVP_START_ADDR	((__MM_VBV_START_ADDR - __MM_SI_VBV_OFFSET - __MM_DMX_DATA_LEN - __MM_DMX_AVP_LEN)&0XFFFFFFFC)

#define __MM_TTX_BS_START_ADDR	__MM_FB2_C_START_ADDR
#define __MM_TTX_PB_START_ADDR	(__MM_TTX_BS_START_ADDR+__MM_TTX_BS_LEN)
#define __MM_SUB_BS_START_ADDR	__MM_DVW_START_ADDR
#define __MM_SUB_PB_START_ADDR	(__MM_SUB_BS_START_ADDR+__MM_SUB_BS_LEN)
#define __MM_HEAP_TOP_ADDR		__MM_DMX_AVP_START_ADDR
#else //( SYS_SDRAM_SIZE == 8,16 )
#define __MM_BUF_TOP_ADDR		0XA0800000
#define __MM_FB0_Y_LEN			0X65400
#define __MM_FB0_C_LEN			0X32C00
#define __MM_FB1_Y_LEN			0
#define __MM_FB1_C_LEN			0
#define __MM_FB2_Y_LEN			0
#define __MM_FB2_C_LEN			0
#define __MM_MAF_LEN			0
#define __MM_DVW_LEN			0
#define __MM_VBV_LEN			0X10000
#define __MM_OSD_LEN			0x65400
#define __MM_DMX_SI_LEN			0
#define __MM_DMX_SI_TOTAL_LEN	(__MM_DMX_SI_LEN*28)
#define __MM_SI_VBV_OFFSET		__MM_DMX_SI_TOTAL_LEN
#define __MM_DMX_DATA_LEN		0
#define __MM_DMX_PCR_LEN		0
#define __MM_DMX_AUDIO_LEN		0
#define __MM_DMX_VIDEO_LEN		0
#define __MM_DMX_AVP_LEN		(__MM_DMX_VIDEO_LEN+__MM_DMX_AUDIO_LEN+__MM_DMX_PCR_LEN)
#define __MM_TTX_BS_LEN			0
#define __MM_TTX_PB_LEN			0
#define __MM_SUB_BS_LEN			0
#define __MM_SUB_PB_LEN			0

#define __MM_FB0_Y_START_ADDR	((__MM_BUF_TOP_ADDR - __MM_FB0_Y_LEN)&0XFFFFFF00)
#define __MM_FB0_C_START_ADDR	((__MM_FB0_Y_START_ADDR - __MM_FB0_C_LEN)&0XFFFFFF00)
#define __MM_FB1_Y_START_ADDR	((__MM_FB0_C_START_ADDR - __MM_FB1_Y_LEN)&0XFFFFFF00)
#define __MM_FB1_C_START_ADDR	((__MM_FB1_Y_START_ADDR - __MM_FB1_C_LEN)&0XFFFFFF00)
#define __MM_FB2_Y_START_ADDR	((__MM_FB1_C_START_ADDR - __MM_FB2_Y_LEN)&0XFFFFFF00)
#define __MM_FB2_C_START_ADDR	((__MM_FB2_Y_START_ADDR - __MM_FB2_C_LEN)&0XFFFFFF00)
#define __MM_MAF_START_ADDR		((__MM_FB2_C_START_ADDR - __MM_MAF_LEN)&0XFFFFFC00)
#define __MM_DVW_START_ADDR		((__MM_MAF_START_ADDR - __MM_DVW_LEN)&0XFFFFFFF0)
#define __MM_VBV_START_ADDR		((__MM_DVW_START_ADDR - __MM_VBV_LEN)&0XFFFFFF00)
#define __MM_OSD_START_ADDR		((__MM_VBV_START_ADDR - __MM_OSD_LEN)&0XFFFFFFF0)
#define __MM_DMX_AVP_START_ADDR	((__MM_OSD_START_ADDR - __MM_SI_VBV_OFFSET - __MM_DMX_DATA_LEN - __MM_DMX_AVP_LEN)&0XFFFFFFFC)

#define __MM_TTX_BS_START_ADDR	((__MM_DMX_AVP_START_ADDR - __MM_TTX_BS_LEN)&0XFFFFFFFC)
#define __MM_TTX_PB_START_ADDR	((__MM_TTX_BS_START_ADDR - __MM_TTX_PB_LEN)&0XFFFFFFFC)
#define __MM_SUB_BS_START_ADDR	__MM_DVW_START_ADDR
#define __MM_SUB_PB_START_ADDR	(__MM_SUB_BS_START_ADDR+__MM_SUB_BS_LEN)
#define __MM_HEAP_TOP_ADDR		__MM_TTX_PB_START_ADDR
#endif

#endif	/* _BOOT_SYS_CONFIG_H_ */

